﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VipSys.SystemEntity;
using VipSys.DataLayer;
using log4net;
using System.IO;
using System.Reflection;
using System.Diagnostics;

[assembly: log4net.Config.XmlConfigurator(Watch =true)]
namespace VipSys
{
    public partial class test : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Employee employee = new SystemEntity.Employee() { EmpNo = "wbl", PassWord = "111111" };
                EmployeeAccess.Instance.GetEmployee(employee, ref employee);
                SysAccount account = new SysAccount();
                account.ID = employee.ID;
                account.Name = employee.Name;
                account.RoleType = "总公司";
                account.Password = employee.PassWord;
                Session["SysAccount"] = account;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            User user = new SystemEntity.User() { Tel = "13616549754", PassWord = "549754" };
            UserAccess.Instance.GetUser(user, ref user);
            SysAccount account = new SysAccount();
            account.ID = user.ID;
            account.Name = user.Name;
            account.RoleType = "会员";
            account.Room = user.Room;
            account.Password = user.PassWord;
            account.Hotel = user.Hotel;
            Session["SysAccount"] = account;
            Response.Redirect("website/SubExamPlace.aspx");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Employee employee = new SystemEntity.Employee() { EmpNo = "wbl", PassWord = "639891" };
            EmployeeAccess.Instance.GetEmployee(employee, ref employee);
            SysAccount account = new SysAccount();
            account.ID = employee.ID;
            account.Name = employee.Name;
            account.RoleType = "总公司";
            account.Password = employee.PassWord;
            Session["SysAccount"]= account;
            Response.Redirect("MainForm.aspx");
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            User user = new SystemEntity.User() { Tel = "13616549754", PassWord = "549754" };
            UserAccess.Instance.GetUser(user, ref user);
            SysAccount account = new SysAccount();
            account.ID = user.ID;
            account.Name = user.Name;
            account.RoleType = "会员";
            account.Room = user.Room;
            account.Password = user.PassWord;
            account.Hotel = user.Hotel;
            Session["SysAccount"] = account;

            Response.Redirect("website/UserInfo.aspx");
        }

        protected void Button4_Click(object sender, EventArgs e)
        {
            HyperLink hlk = new HyperLink();
            hlk.Text = "测试";
            hlk.NavigateUrl = "website/RoomieInfo.aspx?ID=50";
            this.Panel1.Controls.Add(hlk);
        }

        protected void Button5_Click(object sender, EventArgs e)
        {
            //log4net.Config.DOMConfigurator.Configure( new FileInfo("TestLogger.Exe.Config"));
            //log4net.Config.BasicConfigurator.Configure( new log4net.Appender.FileAppender(   new log4net.Layout.PatternLayout("%d   [%t]%-5p %c [%x] - %m%n"),"VipSys.log"));
            log4net.Config.XmlConfigurator.Configure();
          
            //log4net.ILog log = log4net.LogManager.GetLogger("AdoNetAppender_Access");
            //ILog log = LogManager.GetLogger("WebLogger");
            //log.Info("info");
            SystemParam.Instance.Log.Debug("Hello world");
            //log.Error("error", new Exception("hello world! 报错了！"));
            //SystemParam.Instance.Log.Error("error", new Exception("hello world! 报错了！"));
            
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            Employee employee = new SystemEntity.Employee() { EmpNo = "admin", PassWord = "admin" };
            EmployeeAccess.Instance.GetEmployee(employee, ref employee);
            SysAccount account = new SysAccount();
            account.ID = employee.ID;
            account.Name = employee.Name;
            account.RoleType = employee.RoleType;
            account.Password = employee.PassWord;
            Session["SysAccount"]= account;
            Response.Redirect("MainForm.aspx");
        }

        protected void Button7_Click(object sender, EventArgs e)
        {
            Response.Write(SystemParam.Instance.ConnectionString);
        }

        protected void Button8_Click(object sender, EventArgs e)
        {
            SystemParam.Instance.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\wwwroot\\zyldingfang\\wwwroot\\admin\\App_Data\\VipSys.mdb;User Id=;Password=;";
            SystemParam.Instance.DBAccess.ExecuteQuery("select * from Users");
        }

        protected void Button9_Click(object sender, EventArgs e)
        {
            Response.Redirect("UserMag.aspx");
        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            Response.Redirect("HotelRegMag.aspx");
        }

        protected void Button11_Click(object sender, EventArgs e)
        {
            string szSQL = txtSQL.Text.Trim();
            try
            {
                int result = SystemParam.Instance.DBAccess.ExecuteNonQuery(szSQL);
                Response.Write(result);
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
                
            }
        }

        protected void Button12_Click(object sender, EventArgs e)
        {
            Session["SysAccount"]= null;
        }





    }
}